package com.mrjy.video.controller;

import com.mrjy.common.entity.VideoType;
import com.mrjy.video.bo.IVideoTypeBo;
import com.mrjy.video.dto.VideoTypeDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/video/videoType")
public class VideoTypeController {
	@Resource
	private IVideoTypeBo videoTypeBo;
	
	/**
	 * 添加标签
	 * @param videoType
	 * @return
	 */
	@RequestMapping("/insert")
	@ResponseBody
	public Object insert(VideoType videoType,HttpSession session) {
		return videoTypeBo.txInsert(videoType,session);
	}
	
	@RequestMapping("/deleteByIds")
	@ResponseBody
	public Object deleteByIds(int[] ids) {
		return videoTypeBo.txDeleteByIds(ids);
	}

	/**
	 * 启用/禁用
	 * @param videoType
	 * @return
	 */
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(VideoType videoType,HttpSession session) {
		return videoTypeBo.txUpdateDisableFlag(videoType,session);
	}	
		
	/**
	 * 修改
	 * @param videoType
	 * @return
	 */
	@RequestMapping(value="/updateById",method=RequestMethod.POST)
	@ResponseBody
	public Object updateById(VideoType videoType,HttpSession session) {
		return videoTypeBo.txUpdateById(videoType,session);
	}	
	
	@RequestMapping("/queryById")
	@ResponseBody
	public Object queryById(int id) {
		return videoTypeBo.queryById(id);
	}
	
	/**
	 * 分页查询标签--后台系统
	 * @param videoType
	 * @return
	 */
	@RequestMapping("/queryPage")
	@ResponseBody
	public Object queryPage(VideoType videoType,HttpSession session) {
		return videoTypeBo.queryPage(videoType,session);
	}
	
	@RequestMapping("/queryList")
	@ResponseBody
	public Object queryList(VideoType videoType) {
		return videoTypeBo.queryList(videoType);
	}
	/*
	 * 获取起用的视频类型list
	 */
	@RequestMapping("/queryCanUseList")
	@ResponseBody
	public Object queryCanUseList() {
		return videoTypeBo.queryCanUseList();
	}
	
	/**
	 * 分页查询视频列表
	 * @param videoType
	 * @return
	 * @author Javin : isUer =true, isNew = true
	 */
	@RequestMapping("/queryPageList")
	@ResponseBody
	public Object queryPageList(VideoType videoType){
		return videoTypeBo.queryPageList(videoType);
	}
	
	@RequestMapping("/export")
	@ResponseBody
	public Object exportExcel(VideoType videoType,HttpServletResponse response,HttpSession session){
		return videoTypeBo.exportExl(videoType,response,session);
	}
	
	
	@RequestMapping("/getTotal")
	@ResponseBody
	private Object getTotal(VideoType videoType){
		return videoTypeBo.getTotal(videoType);
	}
	
	/**
	 * 微信1.5 
	 * 根据前台传来的dynamicFlag动态展示阶段标签
	 * @param dto
	 * @return
	 */
	@RequestMapping("/queryByDynamicFlag")
	@ResponseBody
	public Object queryByDynamicFlag(VideoTypeDto dto){
		return videoTypeBo.queryByDynamicFlag(dto);
	}

    /**
     * 微信1.6
     * 根据标签的id 和 user_id，来得出当前用户的已经学习完了的记录数
     *
     * @param dto
     * @return
     */
    @RequestMapping("/queryStatisticsTabsByDefault")
    @ResponseBody
    public Object queryStatisticsTabsByDefault(VideoTypeDto dto) {
        return videoTypeBo.queryStatisticsTabsByDefault(dto);
    }
}
